package study.函数式接口;

import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

/**
 * @Author 金贵权
 * @Date 2023/6/15 17:28
 **/
public class Demo05 {
    public static void main(String[] args) {
        Comparator<Apple> comparator = (a,b)->a.getWeight().compareTo(b.getWeight());
        int compare = comparator.compare(new Apple(12), new Apple(16));
        System.out.println(compare);
        List<Apple> apples = Arrays.asList(new Apple(12), new Apple(15), new Apple(9), new Apple(11));
        Comparator.comparing(Apple::getWeight);
        apples.sort(Comparator.comparing(Apple::getWeight));
        System.out.println(apples);

    }
}
